<template>
    <div class="lotteryhb">
        <ul class="redpackul" v-if="lists.length>0">
            <li v-for="(item,index) in lists" v-on:click="showmodal(item)"
                class="(item.State === 1 ? 'overdue' : 'useup')">
                <div class="imgcon">
                    <b>余额</b>
                    <strong><em>￥</em><i>{{item.State === 2 ? item.UsableMoney : ( item.UsableMoney || item.Money)}}</i></strong>
                </div>
                <div class="redinfo">
                    <dl>
                        <dd class="colorred">{{item.LimitLottery}}</dd>
                        <dd class="secborder">{{item.LimitMoneyMsg}}</dd>
                        <dd v-if="Name">{{item.Name}}</dd>
                        <dd class="little" v-html="item.EndTime"/>
                    </dl>
                    <icon name="right"/>
                </div>
            </li>
        </ul>
        <img class="nodata" v-else src='//common-1253410441.file.myqcloud.com/coverimg/20170622203327.png'
             alt="没有数据"/>
        <actionsheet v-model="show" :menus="currdata" theme="android"
                     @on-click-menu="clickfn"/>

    </div>

</template>

<script>
    import {Marquee, Actionsheet, Toast} from 'vux';
    import {namesource, jumptype} from '../../utils/config/common';
    import {getMytoken} from '../../services/common';
    import {nativetonative} from '../../utils/otherfn';
    import axios from 'axios';
    export default {
        components: {
            Marquee,
            Actionsheet,
            Toast
        },
        data() {
            return {
                lists: [],
                show: false,
                currdata: {}
            };
        },
        created() {
            this.getdata();
        },
        methods: {
            /**
             * 获取一些初始化信息
             */
            getdata: async function () {
                var that = this;
                const {token}=await getMytoken();
//                const token = '976e9b95-56c7-48b9-8633-b64c447ee1e1';
                axios.get(`/hd/Handler.ashx?action=1133&params={"UserCode":"${token}"}`)
                        .then(function ({data}) {
                            that.lists = data.data.Item;
                            console.log(that.lists);
                        })
                        .catch(function (error) {
                            console.log(error);
                        })
            },
            showmodal(item){
                if(item.LimitLotteryCode === '') {
                    nativetonative('home');
                    return;
                }
                this.show = true;
                this.currdata = item.LimitLotteryCode.split(',').map((e, i)=>({label: namesource[e], value: e}));
            },
            clickfn(key, item){
                nativetonative(jumptype[key]);
            }
        }
    }
</script>
<style scoped lang="less" rel="stylesheet/less">
    @import "../app";

    .lotteryhb {
        img {
            width: 100%;
            display: block;
            margin-top: 200px;
        }
        h5 {
            font-size: 36px;
            text-align: center;
            margin: 20px 0;
            strong {
                color: #ff5f5f;
            }
        }
        .redpackul {
            margin-top: 10px;
            padding: 0 24px;
            li {
                display: flex;
                height: 230px;
                background: #fff;
                overflow: hidden;
                position: relative;
                margin-top: 20px;
                &::after {
                    content: ' ';
                    position: absolute;
                    right: 0;
                    top: 0;
                    background: url(//common-1253410441.file.myqcloud.com/coverimg/20170608094619.png) no-repeat right;
                    width: 5px;
                    bottom: 0;
                }
                .imgcon {
                    width: 182px;
                    background: url(//common-1253410441.file.myqcloud.com/coverimg/20170607175715.png) transparent no-repeat center;
                    background-size: cover;
                    color: #fff;
                    padding-left: 20px;
                    box-sizing: border-box;
                    b {
                        display: block;
                        line-height: 1;
                        font-size: 28px;
                        margin: 50px 0 18px 0;
                    }
                    strong {
                        line-height: 1;
                        display: block;
                        font-size: 48px;
                        em {
                            font-size: 26px;
                        }
                    }
                }
                .redinfo {
                    font-size: 32px;
                    flex: 1;
                    display: flex;
                    align-items: center;
                    dl {
                        padding: 0 30px;
                        flex: 1;
                    }
                    dd {
                        position: relative;
                        color: @color3;
                        font-size: 26px;
                        margin-bottom: 20px;
                        line-height: 1;
                        &:before {
                            content: ' ';
                            width: 10px;
                            height: 10px;
                            border-radius: 50%;
                            background: @color12;
                            display: inline-block;
                            vertical-align: middle;
                            margin-right: 10px;
                        }
                        &.colorred {
                            font-size: 32px;
                            color: @color6;
                            &::before {
                                background: @color6;
                            }
                        }
                        &.secborder {
                            color: @color1;
                            border-bottom: 1px dotted @color12;
                            padding-bottom: 18px;
                            &::before {
                                background: @color1;
                            }
                        }
                        &.little {
                            font-size: 22px;
                            b {
                                color: @color6;
                                font-weight: 400;
                            }
                        }
                    }
                    svg {
                        color: @color4;
                        margin-right: 18px;
                        width: 42px;
                        height: 42px;
                    }
                }
                &.overdue, &.useup {
                    .redinfo {
                        &::before {
                            background: @color3;
                        }
                        .colorred {
                            color: @color3;
                            &::before {
                                background: @color3;
                            }
                        }
                        .secborder {
                            color: @color3;
                            &::before {
                                background: @color3;
                            }
                        }
                    }
                    .imgcon {
                        background: @color4;
                    }
                }
                &.overdue {
                    dl {
                        position: relative;
                        &::after {
                            position: absolute;
                            content: ' ';
                            width: 140px;
                            height: 95px;
                            background: url(//common-1253410441.file.myqcloud.com/coverimg/20170608100256.png) transparent no-repeat center;
                            background-size: cover;
                            right: 20px;
                            top: -18px;
                        }
                    }
                }
                &.useup {
                    dl {
                        position: relative;
                        &::after {
                            position: absolute;
                            content: ' ';
                            width: 140px;
                            height: 95px;
                            background: url(//common-1253410441.file.myqcloud.com/coverimg/20170608100257.png) transparent no-repeat center;
                            background-size: cover;
                            right: 20px;
                            top: -18px;
                        }
                    }
                }
            }
        }
    }

    .weui-skin_android .weui-actionsheet {
        width: 600px;
    }
</style>